#ifndef EXCEPTION_H
#define EXCEPTION_H

#include "Log.h"

namespace Cvekas {

/// %Cvekas exception
class Exception: public std::exception
{
public:
	/// Constructor
	/// \param message Description of exception
	/// \param file Source file where exception was thrown
	/// \param line Line where exception was thrown
	Exception(const std::string& message, const std::string& file, int line): message(message), file(file), line(line)
	{
#ifdef _DEBUG
		LOG(FORMAT("Exception thrown in %s:%d:%s", % file % line % message));
#endif
	}
	
	/// Destructor
	virtual ~Exception() {}

	/// Provides description of exception
	virtual const char* what() const throw()
	{
		return message.c_str();
	}

protected:
	const std::string message;
	const std::string file;
	const int line;
};

#define EXCEPTION(msg) (Exception((msg), __FILE__, __LINE__))

} // namespace

#endif